Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK-2309 cache link data when initialization is deferred #1369

Merged
merged 5 commits into from
Apr 3, 2024

Conversation

echo-branch
Copy link
Contributor

Reference

SDK-2309 Cache link data when initialization is deferred

Summary

On React Native we had a caching mechanism to store links until the JS layer was ready. This is not working properly when using the optional deferred init on iOS. This moves the caching to the native iOS layer.

Motivation

Fix cold link open when using deferred init on iOS with React Native

Type Of Change

  • Bug fix (non-breaking change which fixes an issue)

Testing Instructions

Enable deferred init with the branch.json
Add a delayed notifyNativeToInit
Install app, but make sure it is fully closed
Open the app with a universal link

Without this change the link will be ignored.
With this change the link will be used with the deferred init.

Also need to test this on React Native.

cc @BranchMetrics/saas-sdk-devs for visibility.

Copy link

codecov bot commented Mar 27, 2024

Codecov Report

Attention: Patch coverage is 33.33333% with 10 lines in your changes are missing coverage. Please review.

Project coverage is 51.16%. Comparing base (4152af5) to head (2009c84).
Report is 13 commits behind head on master.

Files Patch % Lines
Sources/BranchSDK/Branch.m 33.33% 9 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1369      +/-   ##
==========================================
+ Coverage   51.03%   51.16%   +0.13%     
==========================================
  Files          66       66              
  Lines       10126    10133       +7     
  Branches     3714     3718       +4     
==========================================
+ Hits         5168     5185      +17     
+ Misses       4700     4692       -8     
+ Partials      258      256       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nsingh-branch
Copy link
Contributor

What does the latest Allow init calls to come in late. commit do?

}
}
#endif

// Handle case where there's no URI scheme or Universal Link.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code assumed that there would be a follow up link lifecycle call, but with delayed init that call may have already happened and the associated link saved off.

Currently researching if this change has side effects.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After some testing this appears to be a legacy check that hasn't been required in a long time. It did negatively impact apps are are using just an AppDelegate on cold launch with a delayed init. Removing the check fixes the issue.

@echo-branch
Copy link
Contributor Author

What does the latest Allow init calls to come in late. commit do?

Added comment to code view. Still researching if this change is correct.

if (![options.allKeys containsObject:UIApplicationLaunchOptionsURLKey] && ![options.allKeys containsObject:UIApplicationLaunchOptionsUserActivityDictionaryKey]) {
[self initUserSessionAndCallCallback:YES sceneIdentifier:nil urlString:nil];
}
[self initUserSessionAndCallCallback:YES sceneIdentifier:nil urlString:pushURL];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment if there are any assumptions about from which lifecycle call(s) this must go through?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously we assumed that initSession always came first, and other lifecycle calls would follow. With the delay feature, we cannot assume that anymore and cache away links arriving from other lifecycle calls. So now there are no assumptions about where the initSession is coming from.

@echo-branch echo-branch merged commit 08fecfc into master Apr 3, 2024
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants